package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageDTO;
import com.sky.entity.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    //根据分类id统计分类下的菜品数量
    @Select("select count(*) from dish where category_id = #{id}")
    Long countByCid(Long id);

    //添加菜品信息
    void insert(Dish dish);

    //分页查询
    List<DishVO> list(DishPageDTO dishPageDTO);

    //根据ids查询是否关联套餐
    Integer countByIdsAndStatus(Long[] ids, Integer enable);

    //查询id
    @Select("select * from dish where id = #{dishId}")
    Dish getById(Long dishId);

    //删除id
    @Delete("delete from dish where id = #{dishId}")
    void deleteById(Long dishId);

    //修改
    @AutoFill("update")
    void update(Dish dish);


    //根据id查询起售状态列表
    List<Dish> paramsList(DishDTO dishDTO);

    //批量删除菜品
    List<Dish> getByIds(Long[] ids);
}

